package edu.snake.implement.controller.character;

import edu.snake.core.controller.ArenaController;
import edu.snake.core.controller.ArenaController.Direction;
import edu.snake.core.controller.GameEngine;
import edu.snake.implement.model.character.Snake;


public class SnakeController extends BaseCharacterController {

    public SnakeController(Snake character, ArenaController arenaController, GameEngine gameEngine) {
        super(character, arenaController, gameEngine);
    }

    @Override
    public void setDirection(Direction direction) {
        Direction oldDirection = this.direction;
        switch (oldDirection) {
            case UP:
                if (direction == Direction.LEFT) {
                    this.direction = Direction.RIGHT;
                } else if (direction == Direction.RIGHT) {
                    this.direction = Direction.LEFT;
                }
                break;
            case DOWN:
                if (direction == Direction.LEFT) {
                    this.direction = Direction.LEFT;
                } else if (direction == Direction.RIGHT) {
                    this.direction = Direction.RIGHT;
                }
                break;

            case LEFT:
                if (direction == Direction.LEFT) {
                    this.direction = Direction.UP;
                } else if (direction == Direction.RIGHT) {
                    this.direction = Direction.DOWN;
                }
                break;

            case RIGHT:
                if (direction == Direction.LEFT) {
                    this.direction = Direction.DOWN;
                } else if (direction == Direction.RIGHT) {
                    this.direction = Direction.UP;
                }
                break;
        }
    }
}
